|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectcontrolP5.Controller
controlP5.MultiList
public class MultiList
multilist has the effect of a menu-tree. see the example for more information and usage.
/**
* ControlP5 MultiList
* by andreas schlegel, 2009
*/
import controlP5.*;
ControlP5 controlP5;
MultiList l;
void setup() {
size(400,400);
frameRate(30);
controlP5 = new ControlP5(this);
// add a multiList to controlP5.
// elements of the list have default dimensions
// here, a width of 100 and a height of 12
l = controlP5.addMultiList("myList",0,10,100,12);
// create a multiListButton which we will use to
// add new buttons to the multilist
MultiListButton b;
b = l.add("level1",1);
// add items to a sublist of button "level1"
b.add("level11",11).setLabel("level1 item1");
b.add("level12",12).setLabel("level1 item2");
b = l.add("level2",2);
int cnt = 100;
// add some more sublists.
for(int i=0;i<10;i++) {
MultiListButton c = b.add("level2"+(i+1),20+i+1);
c.setLabel("level2 item"+(i+1));
c.setColorBackground(color(64 + 18*i,0,0));
if(i==4) {
// changing the width and the height of a button
// will be inherited by its sublists.
c.setWidth(100);
c.setHeight(20);
}
cnt++;
if(i==4) {
for(int j=0;j<10;j++) {
cnt++;
MultiListButton d;
d = c.add("level2"+i+""+j,250+j+1);
d.setLabel("level2 item"+(i+1)+" "+"item"+(j+1));
d.setColorBackground(color(64 + 18*j,(64 + 18*j)/2,0));
d.setId(cnt);
d.setWidth(200);
}
}
}
MultiListButton cc = (MultiListButton)controlP5.controller("level21");
cc.setHeight(40);
}
void controlEvent(ControlEvent theEvent) {
println(theEvent.controller().name()+" = "+theEvent.value());
// uncomment the line below to remove a multilist item when clicked.
// theEvent.controller().remove();
}
void draw() {
background(0);
}
void keyPressed() {
if(controlP5.controller("level23")!=null) {
println("removing multilist button level23.");
controlP5.controller("level23").remove();
}
}
| Field Summary | |
|---|---|
int |
closeDelay
|
| Fields inherited from interface controlP5.ControlP5Constants |
|---|
acceptClassList, ACTIVE, ALT, ARC, ARRAY, BACKSPACE, BOOLEAN, BOTTOM, CENTER, CONTROL, controlEventClass, CUSTOM, DECREASE, DEFAULT, DELETE, DOWN, ELLIPSE, ENTER, ESCAPE, EVENT, eventMethod, FIELD, FLOAT, HALF_PI, HIDE, HIGHLIGHT, HORIZONTAL, IMAGE, INCREASE, INTEGER, INVALID, KEYCONTROL, LEFT, LINE, LOAD, MENU, METHOD, MOVE, OVER, PI, PRESSED, PRINT, RELEASE, RESET, RIGHT, SAVE, SHIFT, SPRITE, STRING, SWITCH, SWITCH_BACK, SWITCH_FORE, TAB, TOP, TWO_PI, UP, VERBOSE, VERTICAL |
| Constructor Summary | |
|---|---|
MultiList(ControlP5 theControlP5,
Tab theParent,
java.lang.String theName,
int theX,
int theY,
int theWidth,
int theHeight)
|
|
| Method Summary | |
|---|---|
MultiListButton |
add(java.lang.String theName,
int theValue)
add multilist buttons to the multilist. |
void |
addToXMLElement(ControlP5XMLElement theElement)
|
void |
close()
|
void |
close(MultiListInterface theInterface)
|
void |
controlEvent(ControlEvent theEvent)
TODO experimental. |
void |
draw(processing.core.PApplet theApplet)
the default draw function for each controller extending superclass Controller. |
int |
getDirection()
|
void |
mouseReleased()
|
boolean |
observe()
|
void |
occupied(boolean theFlag)
|
void |
open()
|
void |
remove()
remove a multilist. |
void |
setDirection(int theDirection)
|
void |
setup()
|
void |
setValue(float theValue)
set the value of the controller. |
java.util.List<Controller> |
subelements()
|
void |
update()
updates the value of the controller without having to set the value explicitly. |
boolean |
update(processing.core.PApplet theApplet)
|
void |
updateLocation(float theX,
float theY)
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface controlP5.MultiListInterface |
|---|
name |
| Field Detail |
|---|
public int closeDelay
| Constructor Detail |
|---|
public MultiList(ControlP5 theControlP5,
Tab theParent,
java.lang.String theName,
int theX,
int theY,
int theWidth,
int theHeight)
| Method Detail |
|---|
public void setup()
public java.util.List<Controller> subelements()
subelements in interface MultiListInterfacepublic int getDirection()
getDirection in interface MultiListInterfacepublic void setDirection(int theDirection)
public void updateLocation(float theX,
float theY)
updateLocation in interface MultiListInterfacetheX - floattheY - floatpublic void remove()
remove in interface ControllerInterfaceremove in class Controller
public MultiListButton add(java.lang.String theName,
int theValue)
theName - StringtheValue - int
public void controlEvent(ControlEvent theEvent)
controlEvent in interface ControlListenertheEvent - public void draw(processing.core.PApplet theApplet)
Controller
draw in interface CDrawabledraw in interface ControllerInterfacedraw in interface MultiListInterfacedraw in class ControllertheApplet - PAppletControllerDisplaypublic boolean update(processing.core.PApplet theApplet)
theApplet - PApplet
public void occupied(boolean theFlag)
theFlag - booleanpublic boolean observe()
observe in interface MultiListInterfacepublic void close(MultiListInterface theInterface)
close in interface MultiListInterfacetheInterface - MultiListInterfacepublic void close()
close in interface MultiListInterfacepublic void open()
open in interface MultiListInterfacepublic void setValue(float theValue)
Controller
setValue in class ControllertheValue - floatpublic void update()
Controller
update in interface ControllerInterfaceupdate in class Controllerpublic void mouseReleased()
public void addToXMLElement(ControlP5XMLElement theElement)
addToXMLElement in interface ControllerInterfaceaddToXMLElement in interface MultiListInterfacetheElement - ControlP5XMLElement
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||